package com.rimi.live.controller;

import com.rimi.live.bean.Response;
import com.rimi.live.bean.Role;
import com.rimi.live.service.RoleServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author luohengyi
 * 角色模块控制器
 */
@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleServer roleServer;
   
    @RequestMapping("/index")
    public String index(ModelMap map){
        List<Role> allRole = roleServer.getAllRole();
        map.addAttribute("lists",allRole);
        return "role/index";
    }


   
    @RequestMapping("/add")
    public String add(){

        return "role/add";
    }

    @RequestMapping("/insert")
    @ResponseBody
    public String insert(@Validated Role role) {
        roleServer.insertRole(role);
        return roleServer.getResponseSave();
    }

   
    public String edit() {
        return null;
    }

   
    public String update() {
        return null;
    }

   
    public String delete() {
        return null;
    }

   
    public String change() {
        return null;
    }

}
